<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
	</head>
	<body>
		<div id="box">
			
		</div>
		<div class="box2">
			
		</div>
		<script type="text/javascript">
			//获取元素
			function $ (selector) {
				// 获取selector的第一个字符
				var str = selector.charAt(0);
				if (str === "#") {
					//selector.substr(1)  从第一个字符开始
					return document.getElementById(selector.substr(1));
				} else if(str === "."){
					return document.getElementsByClassName(selector.substr(1));
				}
			}
		</script>
	</body>
</html>
